package com.chb.dto;

import com.chb.common.ResultCode;
import lombok.Builder;
import lombok.Data;

/**
 * @description:
 * @author: CHB
 * @create: 2021-10-27 16:42
 **/
@Data
@Builder
public class ResultDto<T> {
    private Boolean success;
    private Integer code;
    private String message;
    private T data;

    public static <T> ResultDto<T> success() {
        return ResultDto.<T>builder().success(true).code(ResultCode.SUCCESS.getCode()).build();
    }
    public static <T> ResultDto<T> success(T data) {
        return ResultDto.<T>builder().success(true).data(data).code(ResultCode.SUCCESS.getCode()).build();
    }
    public T s() {
        return data;
    }

    public <S> T ss() {
        return data;
    }

    public static <T> ResultDto<T> error() {
        return ResultDto.<T>builder().success(false).code(ResultCode.ERROR.getCode()).build();
    }
    public static <T> ResultDto<T> error(Integer code,String message) {
        return ResultDto.<T>builder().success(false).code(code).message(message).build();
    }

}
